package com.ht.daoimpl;

import java.util.List;
import com.ht.dao.HistoryDao;
import com.ht.model.History;

public class HistoryDaoImpl extends HibernateDao implements HistoryDao {


	public int insertHistory(History history) {
		int result = super.insert(history);
		return result;
	}
	

	public int deleteHistory(History history) {
		int result = super.delete(history);
		return result;
	}

	public int updateHistory(History history) {
		int result = this.update(history);
		return result;
	}


	
	public List<History> selectByCon(History history,int curPage ,int pageSize) {
		String hql = "select app from History app where 1=1 ";
		if (history != null) {
			if (history.getId()!= 0) {
				hql = hql + " and Id like '%" + history.getId() + "%' ";
			}
		}
		
		List<History> allemps = super.exeQueryByPage(hql, null,curPage,pageSize);
		
		return allemps;
	}
	
	
	
	public History getHistoryById(History history) {
		Object o = super.get(History.class, history.getId());
		History sa = (o!=null) ? (History)o : null ;
		return sa;
	}
	
	public int getRecordCount(History history) {
		String hql = "select count(*) from History where 1=1 ";
		if (history != null) {
			if (history.getId() != 0) {
				hql = hql + " and id like '%" + history.getId() + "%' ";
			}


		}
		Object o = super.getUniqueObject(hql, null);
        int result = Integer.valueOf(o.toString());
		return result;

	}





}
